home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / nccomp / nonclt.pas < prev   
Pascal/Delphi Source File  |  1995-12-22  |  4KB  |  137 lines

  1. unit Nonclt;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs;
  8.  
  9. type
  10.   TNCComponentPosition = (bpLeft,bpRight);
  11.   TNCClickState = (csUp,csDown);
  12.  
  13.   TNCComponent = class(TComponent)
  14.   private
  15.     { private declarations }
  16.     FPosition : TNCComponentPosition;
  17.     FWidth : integer;
  18.     FDragBy : boolean;
  19.     FPosLeft,FPosRight : integer;
  20.     FParentHandle : HWnd;
  21.     FRPP : integer;
  22.     FBorderValid : boolean;
  23.     FVO : integer;
  24.     FCH : integer;
  25.     FOnClick : TNotifyEvent;
  26.     FOwnerActive : boolean;
  27.     procedure SetPosition(Value : TNCComponentPosition);
  28.   protected
  29.     { protected declaration }
  30.     ParentRect : TRect;
  31.     property PosLeft : integer read FPosLeft write FPosLeft;
  32.     property PosRight : integer read FPosRight write FPosRight;
  33.     property ParentHandle : HWnd read FParentHandle;
  34.     property RelativePaintPos : integer read FRPP write FRPP;
  35.     property BorderValid : boolean read FBorderValid;
  36.     property VerticalOffSet : integer read FVO;
  37.     property CaptionHeight : integer read FCH;
  38.     property ParentActive : boolean read FOwnerActive write FOwnerActive;
  39.   public
  40.     { public declarations }
  41.     constructor Create(AOwner : TComponent); override;
  42.     procedure RePaint; virtual; abstract;
  43.     procedure MouseMove(MouseX, MouseY : integer); virtual;
  44.     procedure LButton(ButtonState : TNCClickState); virtual;
  45.     procedure RButton(ButtonState : TNCClickState); virtual;
  46.     procedure LButtonDblClk; virtual;
  47.     procedure RButtonDblClk; virtual;
  48.     function GetPos : integer;
  49.     function ParentRegister(Wnd : HWnd; PaintPos,
  50.                    VOffSet,CaptionHt : integer): integer;
  51.     function IsCovered(MouseX, MouseY : integer) : boolean;
  52.     procedure ParentState(Active : boolean); virtual;
  53.   published
  54.     { published declarations }
  55.     property Position: TNCComponentPosition read FPosition write SetPosition
  56.                                               default bpRight;
  57.     property Width: integer read FWidth write FWidth;
  58.     property DragBy : boolean read FDragBy write FDragBy default False;
  59. end;
  60.  
  61. implementation
  62.  
  63. { ---=== TNCComponent Methods ===--- }
  64. constructor TNCComponent.Create(AOwner : TComponent);
  65. begin
  66.   inherited Create(AOwner);
  67.   DragBy := False;
  68. end;
  69.  
  70. procedure TNCComponent.SetPosition(Value : TNCComponentPosition);
  71. begin
  72.   if FPosition <> Value then FPosition := Value;
  73. end;
  74.  
  75. function TNCComponent.ParentRegister(Wnd : HWnd; PaintPos,
  76.                       VOffSet, CaptionHt : integer) : integer;
  77. begin
  78.   FParentHandle := Wnd;
  79.   if PaintPos = -1 then
  80.     FBorderValid := False
  81.   else
  82.   begin
  83.     FBorderValid := True;
  84.     RelativePaintPos := PaintPos;
  85.   end;
  86.   FVO := VOffSet;
  87.   FCH := CaptionHt;
  88.   Result := width;
  89. end;
  90.  
  91. function TNCComponent.IsCovered(MouseX,MouseY : integer) : boolean;
  92. begin
  93.   Result := False;
  94.   if (MouseX >= PosLeft) and (MouseX <= PosRight) and (MouseY > VerticalOffSet)
  95.     and (MouseY < (CaptionHeight+VerticalOffSet)) then Result := True;
  96. end;
  97.  
  98. function TNCComponent.GetPos : integer;
  99. begin
  100.   case Position of
  101.     bpLeft :  begin
  102.                 GetPos := RelativePaintPos;
  103.               end;
  104.     bpRight : begin
  105.                 GetPos := (ParentRect.Right-ParentRect.Left)-
  106.                            RelativePaintPos;
  107.               end;
  108.   end;
  109. end;
  110.  
  111. procedure TNCComponent.MouseMove(MouseX, MouseY : integer);
  112. begin
  113. end;
  114.  
  115. procedure TNCComponent.LButton(ButtonState : TNCClickState);
  116. begin
  117. end;
  118.  
  119. procedure TNCComponent.RButton(ButtonState : TNCClickState);
  120. begin
  121. end;
  122.  
  123. procedure TNCComponent.LButtonDblClk;
  124. begin
  125. end;
  126.  
  127. procedure TNCComponent.RButtonDblClk;
  128. begin
  129. end;
  130.  
  131. procedure TNCComponent.ParentState(Active : boolean);
  132. begin
  133.   ParentActive := Active;
  134. end;
  135.  
  136. end.
  137.